﻿namespace HuwmanCode.ServiceProcess

open System.Runtime.InteropServices

[<AutoOpen>]
module internal NativeMethods =
    [<DllImport("advapi32.dll", EntryPoint="QueryServiceConfig", SetLastError=true)>] 
    extern bool QueryServiceConfig(nativeint handle, nativeint serviceConfigQuery, int bufferSize, int& bytesNeeded)

    [<Struct; StructLayout(LayoutKind.Sequential)>]
    type ServiceConfigInfo =
        val mutable ServiceType : int
        val mutable StartType : int
        val mutable ErrorControl : int
        [<MarshalAs (UnmanagedType.LPStr)>]
        val mutable BinaryPathName : string
        [<MarshalAs (UnmanagedType.LPStr)>]
        val mutable LoadOrderGroup : string
        val mutable tagId : int
        [<MarshalAs (UnmanagedType.LPStr)>]
        val mutable Dependencies : string 
        [<MarshalAs (UnmanagedType.LPStr)>]
        val mutable ServiceStartName : string
        [<MarshalAs (UnmanagedType.LPStr)>]
        val mutable DisplayName : string